From ddc7a4667e2ef5f7986d3eac66455d4e470c3a6c Mon Sep 17 00:00:00 2001 From: "emellor@leeni.uk.xensource.com" Date: Fri, 19 May 2006 16:21:43 +0100 Subject: [PATCH] The enforce_dom0_cpus test sets the number of vcpus for the Dom0 and checks to see if they have been set correctly. We found that on multi-proc systems, it takes a certain amount of time for the number of vcpus to change. This patch checks the number of vcpus inside a loop until it is correct or 20 seconds elapse, whichever happens first. If after 20 seconds the number of vcpus is not changed correctly, an error is raised. Signed-off-by: Rajagopalan Subrahmanian --- .../01_enforce_dom0_cpus_basic_pos.py | 32 +++++++++++++++---- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/tools/xm-test/tests/enforce_dom0_cpus/01_enforce_dom0_cpus_basic_pos.py b/tools/xm-test/tests/enforce_dom0_cpus/01_enforce_dom0_cpus_basic_pos.py index 9de44d6aa7..b541cad741 100644 --- a/tools/xm-test/tests/enforce_dom0_cpus/01_enforce_dom0_cpus_basic_pos.py +++ b/tools/xm-test/tests/enforce_dom0_cpus/01_enforce_dom0_cpus_basic_pos.py @@ -65,13 +65,24 @@ if check_status and status != 0: FAIL("\"%s\" returned invalid %i != 0" %(cmd,status)) # 5) check /proc/cpuinfo for cpu count -cmd = "grep \"^processor\" /proc/cpuinfo | wc -l" -status, output = traceCommand(cmd) -if check_status and status != 0: - os.unsetenv("XEND_CONFIG") - restartXend() - FAIL("\"%s\" returned invalid %i != 0" %(cmd,status)) +# It takes some time for the CPU count to change, on multi-proc systems, so check the number of procs in a loop for 20 seconds. +#Sleep inside the loop for a second each time. +timeout = 20 +starttime = time.time() +while timeout + starttime > time.time(): +# Check /proc/cpuinfo + cmd = "grep \"^processor\" /proc/cpuinfo | wc -l" + status, output = traceCommand(cmd) + if check_status and status != 0: + os.unsetenv("XEND_CONFIG") + restartXend() + FAIL("\"%s\" returned invalid %i != 0" %(cmd,status)) +# Has it succeeded? If so, we can leave the loop + if output == str(enforce_dom0_cpus): + break +# Sleep for 1 second before trying again + time.sleep(1) if output != str(enforce_dom0_cpus): os.unsetenv("XEND_CONFIG") restartXend() @@ -94,7 +105,14 @@ if check_status and status != 0: FAIL("\"%s\" returned invalid %i != 0" %(cmd,status)) # check restore worked -num_online = int(getDomInfo("Domain-0", "VCPUs")) +# Since this also takes time, we will do it in a loop with a 20 second timeout. +timeout=20 +starttime=time.time() +while timeout + starttime > time.time(): + num_online = int(getDomInfo("Domain-0", "VCPUs")) + if num_online == dom0_online_vcpus: + break + time.sleep(1) if num_online != dom0_online_vcpus: os.unsetenv("XEND_CONFIG") restartXend() -- 2.30.2